Traversing/API/jQuery - Sample Code
closest([expr])
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="/jquery/js/jquery.js"></script>
<script>
$(document).ready(function(){
$(document).bind("click", function (e) {
$(e.target).closest("li").toggleClass("hilight");
});
});
</script>
<style>
li { margin: 3px; padding: 3px; background: #EEEEEE; }
li.hilight { background: yellow; }
</style>
</head>
<body>
<ul>
<li><b>ここをクリック!</b></li>
<li>bタグの外でも <b>内側でも</b> クリック結果は同じ</li>
</ul>
</body>
</html>
[実行結果]